package com.piz.dao.product;

import java.util.List;

import com.piz.dao.common.PizHiberImpl;
import com.piz.dao.common.UnexpectedDBException;
import com.piz.model.ItemTaste;

/**
 * @author prameetk.sharma
 *
 */
public class TasteDao extends PizHiberImpl<ItemTaste>{

	/**
	 * @return
	 */
	public List<ItemTaste> getAllTastes()
	{
		try {
			String hqlQuery = "from ItemTaste";
			List<ItemTaste> tastes = (List<ItemTaste>) executeHQL(hqlQuery);
			return tastes;
		} catch (Exception e) {
			throw new UnexpectedDBException("No Taste is available.", e);
		}
	}
	
	/**
	 * @param tasteName
	 * @return
	 */
	public List<?> fetchTasteByName(String tasteName) {
		try {
			String hqlQuery = "from ItemTaste t";
			if(tasteName != null && tasteName != "")
			{
				hqlQuery += " where t.tname= '"+tasteName + "'";
			}
			return executeHQL(hqlQuery);
		} catch (Exception e) {
			throw new UnexpectedDBException("DBException in fetching item taste by name.",e);
		}
	}
}
